-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix open issues #4
Conversation
Removes the unused e2etest and include the communication-matirx dir which holds the artifacts and the commatrix-gen binary. Signed-off-by: Lior Noy <[email protected]>
fefcc1d
to
9a38214
Compare
Change the flag passed to `os.OpenFile` from O_APPEND to O_TRUNC so each run will produce clean artifacts. Signed-off-by: Lior Noy <[email protected]>
2b631b8
to
b345759
Compare
c1a2171
to
fecb4f5
Compare
debug/debug.go
Outdated
@@ -9,6 +9,7 @@ import ( | |||
"time" | |||
|
|||
corev1 "k8s.io/api/core/v1" | |||
errutil "k8s.io/apimachinery/pkg/api/errors" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: import this as k8serrors / apierrors or just errors (errutil doesn't provide any meaning)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
endpointslices/endpointslices.go
Outdated
@@ -79,9 +79,7 @@ func ToComDetails(cs *client.ClientSet, epSlicesInfo []EndpointSlicesInfo) ([]ty | |||
// createEPSliceInfos gets lists of EndpointSlices, Services, and Pods and generates | |||
// a slice of EndpointSlicesInfo, each representing a distinct service. | |||
func createEPSliceInfos(epSlicesList *discoveryv1.EndpointSliceList, servicesList *corev1.ServiceList, podsList *corev1.PodList) ([]EndpointSlicesInfo, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should receive the slices of the relevant objects instead of the list ([]EndpointSlice,[]Service, []Pod). this is also relevant for all the other functions that don't care about the specific *List object (e.g getPod, getService)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
endpointslices/endpointslices.go
Outdated
} else { | ||
svc = *service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just deref service at the bottom, the "svc" var just confuses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, thanks. I don't know why it didn't work for me when I first tried it.
ss/ss.go
Outdated
@@ -100,6 +100,12 @@ func toComDetails(ssOutput []string, protocol string, node *corev1.Node) ([]type | |||
if err != nil { | |||
return nil, err | |||
} | |||
name, err := identifyContainerForPort(debugPod, ssEntry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it's not really clear what this function does (and the functions that it calls inside), e.g it says ForPort but receives an ssEntry. mind renaming them and/or adding some comments around them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-worked the naming of the functions and added comments. let me know if this is better now.
ss/ss.go
Outdated
ssOutFilteredTCP := filterStrings(filterOutFn, splitByLines(ssOutTCP)) | ||
ssOutFilteredUDP := filterStrings(filterOutFn, splitByLines(ssOutUDP)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: since both use the same filter, and filterStrings is only called here we can just rename filterStrings to something more meaningful and remove the filterFn semantics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks!
Utilize apimachinery errors package to check if error is of type AlreadyExists, and remove prior check that performs "Get". Signed-off-by: Lior Noy <[email protected]>
Removed unnecessary fields in getNamespaceDefinition function. Signed-off-by: Lior Noy <[email protected]>
Separate var block in the GetIngressEndpointSlicesInfo function. Signed-off-by: Lior Noy <[email protected]>
Reword function comment for clarity. Signed-off-by: Lior Noy <[email protected]>
This commit changes the functions `getPod` and `getService` to return only pointer instead val and bool, so that when it fails to find the required object it returns nil. Also made the required changes in createEPSliceInfos. Signed-off-by: Lior Noy <[email protected]>
Utilize identifyContainerForPort in `toComDetails` so that each ss entry will also include the container name. Also removed unused const `processeNameFieldIdx` Signed-off-by: Lior Noy <[email protected]>
1b5ae23
to
088809e
Compare
README.md
Outdated
``` | ||
|
||
#### Usage of EndpointSlice Resource | ||
### Usage of the EndpointSlice Resource | ||
|
||
This library leverages the EndpointSlice resource to identify the ports the | ||
cluster uses for ingress traffic. Relevant EndpointSlices include those | ||
referencing host-networked pods, Node Port services, LoadBalancer services, | ||
or any custom EndpointSlice labeled with `"ingress":""`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we check for eps with "ingress":""
label?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it's left over from the previous version. removed.
cmd/main.go
Outdated
panic(err) | ||
} | ||
defer func() { | ||
output, err := exec.Command("oc", "delete", "ns", consts.DefaultDebugNamespace).CombinedOutput() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the api instead of the exec command? Can be debug.DeleteNamespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, added the new function
if err != nil { | ||
panic(err) | ||
} | ||
}() | ||
nLock := &sync.Mutex{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing new line
ss/ss.go
Outdated
|
||
_, err = tcpFile.Write([]byte(fmt.Sprintf("node: %s\n%s", node.Name, strings.Join(ssOutFilteredTCP, "\n")))) | ||
_, err = tcpFile.Write([]byte(fmt.Sprintf("node: %s\n%s", node.Name, string(ssOutTCP)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an extra new line here? To separate between each node section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
cmd/main.go
Outdated
nLock := &sync.Mutex{} | ||
g := new(errgroup.Group) | ||
for _, n := range nodesList.Items { | ||
node := n | ||
g.Go(func() error { | ||
cds, err := ss.CreateComDetailsFromNode(cs, &node, tcpFile, udpFile) | ||
nLock.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the lock here? this looks counter-productive (isn't the debug.New the thing we want to make concurrent since it waits for the pod to be created?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that we want to prevent 2 go routines from using the clientset together
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the lock.
commatrix/commatrix.go
Outdated
} | ||
comDetails = append(comDetails, add...) | ||
comDetails = append(comDetails, MNOStaticEntries...) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove newline here, put it after the appends
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} | ||
|
||
func identifyContainerForPort(debugPod *debug.DebugPod, ssEntry string) (string, error) { | ||
// getContainerName receives an ss entry and gets the name of the container exposing this port. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "ss entry" shows up a lot of times in this file, it would be useful to document how it looks like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added an example of ss entry to the README
This commit updates the README.md Signed-off-by: Lior Noy <[email protected]>
Fix the `go test` path in tasks.py. Signed-off-by: Lior Noy <[email protected]>
To fix lint check, added period in end of line of comments. Signed-off-by: Lior Noy <[email protected]>
This commit adds a check in the Makefile to see if the `oc` binary exist. if not, download and install it. Signed-off-by: Lior Noy <[email protected]>
This commit joins both filtering function for the ss entries, and rename it with a better name. Signed-off-by: Lior Noy <[email protected]>
This commit updates the static custom entries to be in struct format and not string. also add ports 111 and 53 for UDP. Signed-off-by: Lior Noy <[email protected]>
This commit modifies the functions respoinsible for extracting the container name of a given ss entry. - Renamed functions. - Added comments. - Changed function order. Signed-off-by: Lior Noy <[email protected]>
Since now the SS entries filter out functions for TCP and UDP are the same, here we modify the filterStrings function to include the filter out condition inside and remove the filterFn semantics. Signed-off-by: Lior Noy <[email protected]>
Modify `CreateComDetailsFromNode` function to write the raw-ss files before filtering the SS entries so that the file will reflect the real raw result. Signed-off-by: Lior Noy <[email protected]>
When using goroutines, the behavior of CreateComDetailsFromNode resulted in the deletion of the debug namespace, causing failure. Here, we relocate the creation and deletion of the debug namespace outside of the function to support running this function in parallel threads.
This commit changes the logic of `parseComDetail` function to log warning when can't extract service name, and set it to empty, instead of returning an error. This is to prevent the matrix generation from failing due to an `SS` entry without a service name like the following: `UNCONN 0 0 [::]:6081 [::]:* ` Signed-off-by: Lior Noy <[email protected]>
Added the service `ovn-kubernetes geneve` on port 6081 for MNO only, as part of the static-custom-entries.go. Signed-off-by: Lior Noy <[email protected]>
Fills fields for entires lacking information. Signed-off-by: Lior Noy <[email protected]>
This commit removes from the static custom enties the ports 9001 and 9192, which already exist as an endpointslice, and adds a call for remove duplications functions before returning the communcation matrix, to protect against future duplications. Signed-off-by: Lior Noy <[email protected]>
This PR fixes open issues.